/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package vue;

import ecouteurs.EcouteurPheromones;
import ecouteurs.EcouteurReinit;
import ecouteurs.EcouteurRessources;
import java.awt.Color;
import java.awt.GridLayout;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSlider;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.border.LineBorder;

/**
 *
 * @author Baptiste
 */
public class JPanelParametrisation extends JPanel{
    
    public JPanelParametrisation(){
        
        GridLayout gl = new GridLayout(7,2);
        this.setLayout(gl);
        
        JLabel lblAgents = new JLabel("Nombre d'agents ");
        JTextField txtAgents = new JTextField("1");
        JPanel panAgents = new JPanel();
        panAgents.add(lblAgents);
        panAgents.add(txtAgents);
        this.add(panAgents);
        
        JLabel lblRessources = new JLabel("Nombres de ressources");
        JTextField txtRessources = new JTextField("650");
        JPanel panRessources = new JPanel();
        panRessources.add(lblRessources);
        panRessources.add(txtRessources);
        this.add(panRessources);
        
        JCheckBox afficherRessources = new JCheckBox("Afficher Ressources  ", true);
        JPanel panAfficher = new JPanel();
        panAfficher.add(afficherRessources);
        this.add(panAfficher);
        
        JCheckBox ramasser = new JCheckBox("Ramasser Ressources", true);
        JPanel panRamasser = new JPanel();
        panRamasser.add(ramasser);
        this.add(panRamasser);
        
        JCheckBox ephemeres = new JCheckBox("Ressources périssables", false);
        JPanel panEphemeres = new JPanel();
        panEphemeres.add(ephemeres);
        this.add(panEphemeres);
        
        afficherRessources.addMouseListener(new EcouteurRessources(ramasser, afficherRessources, txtRessources, ephemeres));
        
        JLabel lblStepNumber = new JLabel("Nombre d'étapes de la simulation");
        JTextField txtStepNumber = new JTextField("100");
        JPanel panStepNumber = new JPanel();
        panStepNumber.add(lblStepNumber);
        panStepNumber.add(txtStepNumber);
        this.add(panStepNumber);
        
        JLabel lblVitesse = new JLabel("Délai (ms)");
        JSlider setVitesse = new JSlider(SwingConstants.HORIZONTAL, 0, 2000, 400);
        setVitesse.setMajorTickSpacing(500);
        setVitesse.setMinorTickSpacing(100);
        setVitesse.setPaintTicks(true);
        setVitesse.setPaintLabels(true);
        JPanel panVitesse = new JPanel();
        panVitesse.add(lblVitesse);
        panVitesse.add(setVitesse);
        this.add(panVitesse);
        
        //EnablePheromones
        JCheckBox enablePheromones = new JCheckBox("Activation des phéromones", true);
        JPanel panEnablePheromones = new JPanel();
        panEnablePheromones.add(enablePheromones);
        this.add(panEnablePheromones);
        
        //LifespanPheromones
        JLabel lblLifePhero = new JLabel("Durée de vie des phéromones");
        JTextField txtLifePhero = new JTextField("100");
        JPanel panLifePhero = new JPanel();
        panLifePhero.add(lblLifePhero);
        panLifePhero.add(txtLifePhero);
        this.add(panLifePhero);
        
        //Champ attractif droit
        JCheckBox champAttractif = new JCheckBox("Activation champ attractif droit", false);
        JPanel panChampAttractif = new JPanel();
        panChampAttractif.add(champAttractif);
        this.add(panChampAttractif);
        
        //Attraction par phéromone
        JCheckBox attractPheromone = new JCheckBox("Phéromones attractives", false);
        JPanel panAttractPheromone = new JPanel();
        panAttractPheromone.add(attractPheromone);
        this.add(panAttractPheromone);
        
        //Ephemeritude des phéromones (01:52)
        JCheckBox ephemerePheromone = new JCheckBox("Phéromones éphémères", true);
        JPanel panEphemerePheromone = new JPanel();
        panEphemerePheromone.add(ephemerePheromone);
        this.add(panEphemerePheromone);
        
        enablePheromones.addMouseListener(new EcouteurPheromones(enablePheromones, ephemerePheromone, txtLifePhero, attractPheromone));
                
        JButton reInit = new JButton("Réinitialiser");
        reInit.addMouseListener(new EcouteurReinit(txtAgents, txtRessources, ramasser, txtStepNumber, setVitesse, ephemeres,
                champAttractif, enablePheromones, ephemerePheromone, txtLifePhero, attractPheromone));
        JPanel panButon = new JPanel();
        panButon.add(reInit);
        this.add(panButon);
        
       /* ButtonGroup bg = new ButtonGroup();
        bg.add(champAttractif);
        bg.add(attractPheromone);
        champAttractif.addMouseListener(new EcouteurGroupe(champAttractif, attractPheromone, bg));
        attractPheromone.addMouseListener(new EcouteurGroupe(attractPheromone, champAttractif, bg));*/

        
        this.setBorder(new LineBorder(Color.BLACK));
        
    }

}
